package cn.iocoder.ny.module.activity.controller.admin.login;

import cn.iocoder.ny.module.activity.controller.admin.login.vo.TpLoginVo;
import cn.iocoder.ny.module.activity.service.ITpLoginService;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.admin.auth.vo.AuthLoginRespVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

/**
 * @author luchunhong
 * @date 2024/11/19/ 15:17
 * @description:
 */

@RestController
@RequestMapping("tpLogin")
public class LoginController {

    @Resource
    private ITpLoginService tpLoginService;

    /**
     * 微信授权头像昵称登录
     */
    @RequestMapping("wxLogin")
    @PermitAll
    public CommonResult<Object> wxLogin(@RequestBody TpLoginVo tpLoginVo) throws Exception {
        try {
            AuthLoginRespVO authLoginRespVO = tpLoginService.wxLogin(tpLoginVo);
            return CommonResult.success(authLoginRespVO);

        } catch (RuntimeException e) {
            return CommonResult.error(500,e.getMessage());
        }
    }
}
